package com.gaohe.web.controller.scp;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.scp.domain.CsCarBelong;
import com.gaohe.scp.service.ICsCarBelongService;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.common.core.page.TableDataInfo;

/**
 * 车辆归属Controller
 *
 * @author liuxiangyu
 * @date 2025-03-25
 */
@RestController
@RequestMapping("/scp/belong")
public class CsCarBelongController extends BaseController
{
    @Autowired
    private ICsCarBelongService csCarBelongService;

    /**
     * 查询车辆归属列表
     */
//    @PreAuthorize("@ss.hasPermi('scp:belong:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsCarBelong csCarBelong)
    {
        startPage();
        List<CsCarBelong> list = csCarBelongService.selectCsCarBelongList(csCarBelong);
        return getDataTable(list);
    }

    /**
     * 导出车辆归属列表
     */
//    @PreAuthorize("@ss.hasPermi('scp:belong:export')")
    @Log(title = "车辆归属", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsCarBelong csCarBelong)
    {
        List<CsCarBelong> list = csCarBelongService.selectCsCarBelongList(csCarBelong);
        ExcelUtil<CsCarBelong> util = new ExcelUtil<CsCarBelong>(CsCarBelong.class);
        util.exportExcel(response, list, "车辆归属数据");
    }

    /**
     * 获取车辆归属详细信息
     */
//    @PreAuthorize("@ss.hasPermi('scp:belong:query')")
    @GetMapping(value = "/{belongId}")
    public AjaxResult getInfo(@PathVariable("belongId") Long belongId)
    {
        return success(csCarBelongService.selectCsCarBelongByBelongId(belongId));
    }

    /**
     * 新增车辆归属
     */
//    @PreAuthorize("@ss.hasPermi('scp:belong:add')")
    @Log(title = "车辆归属", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsCarBelong csCarBelong)
    {
        return toAjax(csCarBelongService.insertCsCarBelong(csCarBelong));
    }

    /**
     * 修改车辆归属
     */
//    @PreAuthorize("@ss.hasPermi('scp:belong:edit')")
    @Log(title = "车辆归属", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsCarBelong csCarBelong)
    {
        return toAjax(csCarBelongService.updateCsCarBelong(csCarBelong));
    }

    /**
     * 删除车辆归属
     */
//    @PreAuthorize("@ss.hasPermi('scp:belong:remove')")
    @Log(title = "车辆归属", businessType = BusinessType.DELETE)
	@DeleteMapping("/{belongIds}")
    public AjaxResult remove(@PathVariable Long[] belongIds)
    {
        return toAjax(csCarBelongService.deleteCsCarBelongByBelongIds(belongIds));
    }
}
